<?php

/**
 * This is the model class for table "hosts".
 *
 * The followings are the available columns in table 'hosts':
 * @property integer $hosts_id
 * @property string $hosts_ip
 * @property string $hosts_name
 * @property string $hosts_hardware
 * @property string $hosts_so
 * @property string $hosts_mac
 * @property string $hosts_adaptador
 * @property integer $hosts_usuarios
 * @property integer $hosts_liberados
 *
 * The followings are the available model relations:
 * @property Usuarios $hostsUsuarios
 * @property Liberados $hostsLiberados
 */
class Host extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Host the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'hosts';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('hosts_ip, hosts_name, hosts_mac, hosts_liberados', 'required'),
			array('hosts_liberados', 'numerical', 'integerOnly'=>true),
			array('hosts_ip, hosts_name, hosts_hardware, hosts_so, hosts_mac, hosts_adaptador', 'length', 'max'=>50),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('hosts_id, hosts_ip, hosts_name, hosts_hardware, hosts_so, hosts_mac, hosts_adaptador, hosts_usuarios, hosts_liberados', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'hostsUsuarios' => array(self::BELONGS_TO, 'Usuarios', 'hosts_usuarios'),
			'hostsLiberados' => array(self::BELONGS_TO, 'Liberados', 'hosts_liberados'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'hosts_id' => 'Hosts',
			'hosts_ip' => 'Hosts Ip',
			'hosts_name' => 'Hosts Name',
			'hosts_hardware' => 'Hosts Hardware',
			'hosts_so' => 'Hosts So',
			'hosts_mac' => 'Hosts Mac',
			'hosts_adaptador' => 'Hosts Adaptador',
			'hosts_usuarios' => 'Hosts Usuarios',
			'hosts_liberados' => 'Hosts Liberados',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('hosts_id',$this->hosts_id);
		$criteria->compare('hosts_ip',$this->hosts_ip,true);
		$criteria->compare('hosts_name',$this->hosts_name,true);
		$criteria->compare('hosts_hardware',$this->hosts_hardware,true);
		$criteria->compare('hosts_so',$this->hosts_so,true);
		$criteria->compare('hosts_mac',$this->hosts_mac,true);
		$criteria->compare('hosts_adaptador',$this->hosts_adaptador,true);
		$criteria->compare('hosts_usuarios',$this->hosts_usuarios);
		$criteria->compare('hosts_liberados',$this->hosts_liberados);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}